<!--
 * @Description: 评价台账详情
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-08-31 09:57:33
 * @LastEditTime: 2021-09-15 11:24:31
 * @FilePath: \cscec-pms-admin\src\views\design\resource\projectLedger\detail.vue
-->
<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- 查看设计资源评价 -->
    <a-card>
      <title-name title="查看设计资源评价" />
      <custom-form
        ref="form"
        :is-validate="true"
        :edit-model="''"
        :form="form"
        :form-list="formOption"
      />
    </a-card>
    <!-- 查看设计资源评价 -->
    <!-- 设计资源评价列表 -->
    <a-card>
      <title-name title="设计资源评价列表" />
      <a-tabs
        v-model="tabsKey"
        @change="handleChange"
      >
        <a-tab-pane
          key="25001"
          tab="项目部"
          :disabled="loading"
        >
          <!-- 项目部 -->
          <b-table
            ref="25001"
            :columns="columns1"
            :request="loadData"
            :scroll="{x:2600}"
            :page-keys=" ['pageNo', 'pageSize', 'totalSize']"
            :is-show-count-bar="false"
          />
          <!-- 项目部 -->
        </a-tab-pane>
        <a-tab-pane
          key="25002"
          tab="分公司"
          force-render
          :disabled="loading"
        >
          <!-- 分公司 -->
          <b-table
            ref="25002"
            :columns="columns2"
            :request="loadData"
            :scroll="{x:2600}"
            :page-keys=" ['pageNo', 'pageSize', 'totalSize']"
            :is-show-count-bar="false"
          />
          <!-- 分公司 -->
        </a-tab-pane>
        <a-tab-pane
          key="25003"
          tab="公司"
          force-render
          :disabled="loading"
        >
          <!-- 公司 -->
          <b-table
            ref="25003"
            :columns="columns2"
            :request="loadData"
            :scroll="{x:2600}"
            :page-keys=" ['pageNo', 'pageSize', 'totalSize']"
            :is-show-count-bar="false"
          />
          <!-- 公司 -->
        </a-tab-pane>
      </a-tabs>
    </a-card>
    <!-- 设计资源评价列表 -->
    <div class="page-btn-right-top">
      <a-button
        type="primary"
        @click="closeForm"
      >
        关闭
      </a-button>
    </div>
  </base-breadcrumb>
</template>
<script>
import { formOption, columns1, columns2 } from './model.js'
import { ledger } from '@/api/project/branchEvaluate'
export default {
  name: 'ProjectLedgerDetail',
  components: {},
  data() {
    return {
      // 标签key
      tabsKey: '25001',
      // 表单
      form: {},
      // 表单配置
      formOption,
      // 表头
      columns1,
      columns2,
      loading: false,
      // 表格数据加载
      loadData: async (q) => {
        try {
          this.loading = true
          const { designResourceName, year } = this.$route.query
          const res = await ledger({
            ...q,
            designResourceName,
            year,
            statusCode: 2,
            evaluationTypeCode: this.tabsKey
          })
          if (res.code === 200) {
            return { code: 200, data: res.data, ...res }
          }
          return { code: 200, data: [] }
        } catch (error) {
          return { code: 200, data: [] }
        } finally {
          this.loading = false
        }
      }
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    /**
     * @description: 设计资源评价
     * @param {void}
     * @return {void}
     */
    getData() {
      this.form = this.$route.query
    },
    /**
     * @description: 标签页变化
     * @param {string} key
     * @return {void}
     */
    handleChange() {
      this.$refs[this.tabsKey].getData(null, true)
    },
    /**
     * @description: 关闭
     * @param {void}
     * @return {void}
     */
    closeForm() {
      this.$multiTab.close()
    }
  }
}
</script>
<style lang="less" scoped>
</style>
